package com.store.controller;

import com.store.domain.R;
import com.store.domain.dto.OrderDto;
import com.store.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/6/26
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @GetMapping
    public R getUserOrder(){
        return orderService.getUserOrder();
    }
    @GetMapping("{orderId}")
    public R getOrderById(@PathVariable String orderId){
        return orderService.getOrderById(orderId);
    }
    @PutMapping("complete/{orderId}")
    public R sureOrder(@PathVariable String orderId){
        return orderService.sureOrder(orderId);
    }
    @PutMapping("close/{orderId}")
    public R closeOrder(@PathVariable String orderId){
        return orderService.closeOrder(orderId);
    }
    @PostMapping
    public R submitOrder(@RequestBody OrderDto orderDto){
        return orderService.submitOrder(orderDto);
    }
    @PutMapping("pay/{id}")
    public R payOrder(@PathVariable String id){
        return orderService.payOrder(id);
    }
}
